﻿@using IBS.Model
@model IEnumerable<IBS.Model.Card>

<p>Select the card you are going to work with.</p>

@{
    var grid = new WebGrid(
        source: Model,
        canSort: false,
        canPage: false);
}
@helper BalanceTag(dynamic item){
    <b>
    @ViewBag.AccountService.GetCurrentBalance(item.Account).Amount.ToString("0.####")
    </b>
}
<script>
    var rowClickHandler = function () { }
    $(function () {
        $('tbody tr.row').live('hover', function () {
            $(this).toggleClass('clickable');
        }).live('click', rowClickHandler);
        
    });
</script>

@grid.GetHtml(
    tableStyle: "grid",
    headerStyle: "header",
    rowStyle: "row",
    footerStyle: "footer",
    alternatingRowStyle: "row",
    columns: grid.Columns (
        grid.Column("Number", "Card #", style:"textCol"),
            grid.Column("Type", format: a => (CardType)a.Type, style: "textCol"),
             grid.Column("Balance", format: a => BalanceTag(a), style: "textCol"),
             grid.Column("Account.Currency.ISO", "Currency", style: "textCol"),
        grid.Column("IsBlocked", "Is Blocked", style:"textCol block")
        
    ))
